package com.tozed.test;

import com.tozed.util.Util;

import android.hardware.usb.UsbAccessory;
import android.os.Environment;

public class Constant
{
	public final static String TAG = "FunctionTest";
	public final static String KEY_IDCARD = "idcard";
	public final static String KEY_SMCARD = "smcard";
	public final static String KEY_PRINTER = "printer";
	public final static String KEY_CAMERA = "camera";
	public final static String KEY_MAGNETIC_CARD = "magneticcard";
	
	public final static String KEY_PSAMCARD 	= "psamcard";
	public final static String KEY_LCD 	= "lcd";
	public final static String KEY_TOUCHPANEL 	= "touchpanel";
	public final static String KEY_RING = "ring";
	public final static String KEY_SPEAKER = "speaker";
	public final static String KEY_KEYPAD 	= "keypad";
	public final static String KEY_MOBILE_NETWORK 	= "mobile_network";
	public final static String KEY_ETHERNET 	= "ethernet";
	public final static String KEY_WIFI 	= "wifi";
	
	public final static String KEY_BLUETOOTH 	= "bluetooth";
	public final static String KEY_FM 			= "fm";
	public final static String KEY_SDCARD 		= "sdcard";
	public final static String KEY_USB 			= "usb";
	
	public final static int REQUEST_IDCARD = 100;
	public final static int REQUEST_SMCARD = 101;
	public final static int REQUEST_PRINTER = 102;
	public final static int REQUEST_CAMERA = 103;
	public final static int REQUEST_MAGNETIC_CARD = 104;
	public final static int REQUEST_PSAMCARD = 105;
	public final static int REQUEST_LCD = 106;
	public final static int REQUEST_TOUCHPANEL = 107;
	public final static int REQUEST_RING = 108;
	public final static int REQUEST_SPEAKER = 109;
	public final static int REQUEST_KEYPAD = 110;
	public final static int REQUEST_MOBILE_NETWORK = 111;
	public final static int REQUEST_ETHERNET = 112;
	public final static int REQUEST_WIFI = 113;
	public final static int REQUEST_BLUETOOTH = 114;
	public final static int REQUEST_FM = 115;
	public final static int REQUEST_SDCARD = 116;
	public final static int REQUEST_USB = 117;
	
	public final static int REQUEST_MULTI_TEST = 200;
	public final static int REQUEST_MOTE_MODULE_TEST = 201;
	
	public final static String[] KEYS_FOR_TEST = {
		KEY_IDCARD, KEY_SMCARD, KEY_PRINTER, KEY_CAMERA, KEY_MAGNETIC_CARD,
		KEY_PSAMCARD, KEY_LCD, KEY_TOUCHPANEL, KEY_RING, KEY_SPEAKER, 
		KEY_KEYPAD, KEY_MOBILE_NETWORK, KEY_WIFI, KEY_ETHERNET, KEY_BLUETOOTH, 
		KEY_FM, KEY_SDCARD, KEY_USB
	};
	
	public final static String[] KEYS_FOR_AUTOTEST = {
		KEY_IDCARD, KEY_SMCARD, KEY_PRINTER, 
		KEY_PSAMCARD, KEY_LCD, KEY_RING, 
		KEY_SDCARD
	};

	
	public final static int TYPE_TEST_SINGLE = 1;
	public final static int TYPE_TEST_MULTI = 2;
	public final static int TYPE_TEST_AGING = 3;
	
	// map res: {key, data{resId, activityClss, reqCode}}
	
	public final static String TEST_PATH = Environment.getExternalStorageDirectory() + "/TozedTest";
	
	public static String getTestKeyString(String testKey){
		String str;
		
		if (KEY_IDCARD.equals(testKey)){
			str = Util.getResString(R.string.str_test_idcard);
		}else if (KEY_SMCARD.equals(testKey)){
			str = Util.getResString(R.string.str_test_smcard);
		}else if (KEY_PRINTER.equals(testKey)){
			str = Util.getResString(R.string.str_test_printer);
		}else if (KEY_CAMERA.equals(testKey)){
			str = Util.getResString(R.string.str_test_camera);
		}else if (KEY_MAGNETIC_CARD.equals(testKey)){
			str = Util.getResString(R.string.str_test_magneticcard);
		}else if (KEY_PSAMCARD.equals(testKey)){
			str = Util.getResString(R.string.str_test_psamcard);
		}else if (KEY_LCD.equals(testKey)){
			str = Util.getResString(R.string.str_test_lcd);
		}else if (KEY_TOUCHPANEL.equals(testKey)){
			str = Util.getResString(R.string.str_test_touchpanel);
		}else if (KEY_RING.equals(testKey)){
			str = Util.getResString(R.string.str_test_ring);
		}else if (KEY_SPEAKER.equals(testKey)){
			str = Util.getResString(R.string.str_test_speaker);
		}else if (KEY_KEYPAD.equals(testKey)){
			str = Util.getResString(R.string.str_test_keypad);
		}else if (KEY_MOBILE_NETWORK.equals(testKey)){
			str = Util.getResString(R.string.str_test_mobilenewwork);
		}else if (KEY_ETHERNET.equals(testKey)){
			str = Util.getResString(R.string.str_test_ethernet);
		}else if (KEY_WIFI.equals(testKey)){
			str = Util.getResString(R.string.str_test_wifi);
		}else if (KEY_BLUETOOTH.equals(testKey)){
			str = Util.getResString(R.string.str_test_bluetooth);
		}else if (KEY_FM.equals(testKey)){
			str = Util.getResString(R.string.str_test_fm);
		}else if (KEY_SDCARD.equals(testKey)){
			str = Util.getResString(R.string.str_test_sdcard);
		}else if (KEY_USB.equals(testKey)){
			str = Util.getResString(R.string.str_test_usb);
		}else{
			str = "";
		}
		
		return str;
	}
	
	public static Class<?> getTestActivity(String testKey){
		Class<?> cls = null;
		
		if (KEY_IDCARD.equals(testKey)){
			cls = IDCardTestActivity.class;
		}else if (KEY_SMCARD.equals(testKey)){
			cls = SMCardTestActivity.class;
		}else if (KEY_PRINTER.equals(testKey)){
			cls = PrinterTestActivity.class;
		}else if (KEY_CAMERA.equals(testKey)){
			cls = CameraTestActivity.class;
		}else if (KEY_MAGNETIC_CARD.equals(testKey)){
			cls = MagneticCardTestActivity.class;
		}else if (KEY_PSAMCARD.equals(testKey)){
			cls = PsamcardTestActivity.class;
		}else if (KEY_LCD.equals(testKey)){
			cls = LcdTestActivity.class;
		}else if (KEY_TOUCHPANEL.equals(testKey)){
			cls = TouchscreenTestActivity.class;
		}else if (KEY_RING.equals(testKey)){
			cls = RingTestActivity.class;
		}else if (KEY_SPEAKER.equals(testKey)){
			cls = SpeakerTestActivity.class;
		}else if (KEY_KEYPAD.equals(testKey)){
			cls = KeypadTestActivity.class;
		}else if (KEY_MOBILE_NETWORK.equals(testKey)){
			cls = MobileNetworkTestActivity.class;
		}else if (KEY_ETHERNET.equals(testKey)){
			cls = EthernetTestActivity.class;
		}else if (KEY_WIFI.equals(testKey)){
			cls = WifiTestActivity.class;
		}else if (KEY_BLUETOOTH.equals(testKey)){
			cls = BluetoothTestActivity.class;
		}else if (KEY_FM.equals(testKey)){
			//cls = FmTestActivity.class;
			cls = FmTest2Activity.class;
		}else if (KEY_SDCARD.equals(testKey)){
			cls = SDCardTestActivity.class;
		}else if (KEY_USB.equals(testKey)){
			cls = UsbTestActivity.class;
		}
		
		return cls;
	}
	
	public static int getTestRequestCode(String testKey){
		int reqCode = -1;
		
		if (KEY_IDCARD.equals(testKey)){
			reqCode = REQUEST_IDCARD;
		}else if (KEY_SMCARD.equals(testKey)){
			reqCode = REQUEST_SMCARD;
		}else if (KEY_PRINTER.equals(testKey)){
			reqCode = REQUEST_PRINTER;
		}else if (KEY_CAMERA.equals(testKey)){
			reqCode = REQUEST_CAMERA;
		}else if (KEY_MAGNETIC_CARD.equals(testKey)){
			reqCode = REQUEST_MAGNETIC_CARD;
		}else if (KEY_PSAMCARD.equals(testKey)){
			reqCode = REQUEST_PSAMCARD;
		}else if (KEY_LCD.equals(testKey)){
			reqCode = REQUEST_LCD;
		}else if (KEY_TOUCHPANEL.equals(testKey)){
			reqCode = REQUEST_TOUCHPANEL;
		}else if (KEY_RING.equals(testKey)){
			reqCode = REQUEST_RING;
		}else if (KEY_SPEAKER.equals(testKey)){
			reqCode = REQUEST_SPEAKER;
		}else if (KEY_KEYPAD.equals(testKey)){
			reqCode = REQUEST_KEYPAD;
		}else if (KEY_MOBILE_NETWORK.equals(testKey)){
			reqCode = REQUEST_MOBILE_NETWORK;
		}else if (KEY_ETHERNET.equals(testKey)){
			reqCode = REQUEST_ETHERNET;
		}else if (KEY_WIFI.equals(testKey)){
			reqCode = REQUEST_WIFI;
		}else if (KEY_BLUETOOTH.equals(testKey)){
			reqCode = REQUEST_BLUETOOTH;
		}else if (KEY_FM.equals(testKey)){
			reqCode = REQUEST_FM;
		}else if (KEY_SDCARD.equals(testKey)){
			reqCode = REQUEST_SDCARD;
		}else if (KEY_USB.equals(testKey)){
			reqCode = REQUEST_USB;
		}
		
		return reqCode;
	}
	
	public static int getTestDrawableId(String testKey){
		int nDrawableId = R.drawable.ic_default;
		
		if (KEY_IDCARD.equals(testKey)){
			nDrawableId = R.drawable.ic_idcard2;
		}else if (KEY_SMCARD.equals(testKey)){
			nDrawableId = R.drawable.ic_smcard;
		}else if (KEY_PRINTER.equals(testKey)){
			nDrawableId = R.drawable.ic_printer2;
		}else if (KEY_CAMERA.equals(testKey)){
			nDrawableId = R.drawable.ic_camera3;
		}else if (KEY_MAGNETIC_CARD.equals(testKey)){
			nDrawableId = R.drawable.ic_magneticcard;
		}else if (KEY_PSAMCARD.equals(testKey)){
			nDrawableId = R.drawable.ic_psamcard;
		}else if (KEY_LCD.equals(testKey)){
			nDrawableId = R.drawable.ic_lcd;
		}else if (KEY_TOUCHPANEL.equals(testKey)){
			nDrawableId = R.drawable.ic_touchpanel;
		}else if (KEY_RING.equals(testKey)){
			nDrawableId = R.drawable.ic_sound;
		}else if (KEY_SPEAKER.equals(testKey)){
			nDrawableId = R.drawable.ic_speaker;
		}else if (KEY_KEYPAD.equals(testKey)){
			nDrawableId = R.drawable.ic_keypad;
		}else if (KEY_MOBILE_NETWORK.equals(testKey)){
			nDrawableId = R.drawable.ic_mobilenetwork;
		}else if (KEY_ETHERNET.equals(testKey)){
			nDrawableId = R.drawable.ic_ethernet;
		}else if (KEY_WIFI.equals(testKey)){
			nDrawableId = R.drawable.ic_wifi;
		}else if (KEY_BLUETOOTH.equals(testKey)){
			nDrawableId = R.drawable.ic_bluetooth;
		}else if (KEY_FM.equals(testKey)){
			nDrawableId = R.drawable.ic_fm;
		}else if (KEY_SDCARD.equals(testKey)){
			nDrawableId = R.drawable.ic_sdcard;
		}else if (KEY_USB.equals(testKey)){
			nDrawableId = R.drawable.ic_usb;
		}
		
		return nDrawableId;
	}
	
	public static String getTestKeyByRequestCode(int reqCode){
		String strTestKey = null;
		
		switch (reqCode){
			case REQUEST_IDCARD: strTestKey = KEY_IDCARD; break;
			case REQUEST_SMCARD: strTestKey = KEY_SMCARD; break;
			case REQUEST_PRINTER: strTestKey = KEY_PRINTER; break;
			case REQUEST_CAMERA: strTestKey = KEY_CAMERA; break;
			case REQUEST_MAGNETIC_CARD: strTestKey = KEY_MAGNETIC_CARD; break;
			case REQUEST_PSAMCARD: strTestKey = KEY_PSAMCARD; break;
			case REQUEST_LCD: strTestKey = KEY_LCD; break;
			case REQUEST_TOUCHPANEL: strTestKey = KEY_TOUCHPANEL; break;
			case REQUEST_RING: strTestKey = KEY_RING; break;
			case REQUEST_SPEAKER: strTestKey = KEY_SPEAKER; break;
			case REQUEST_KEYPAD: strTestKey = KEY_KEYPAD; break;
			case REQUEST_MOBILE_NETWORK: strTestKey = KEY_MOBILE_NETWORK; break;
			case REQUEST_ETHERNET: strTestKey = KEY_ETHERNET; break;
			case REQUEST_WIFI: strTestKey = KEY_WIFI; break;
			case REQUEST_BLUETOOTH: strTestKey = KEY_BLUETOOTH; break;
			case REQUEST_FM: strTestKey = KEY_FM; break;
			case REQUEST_SDCARD: strTestKey = KEY_SDCARD; break;
			case REQUEST_USB: strTestKey = KEY_USB; break;	
		}
		
		return strTestKey;
	}
}
